<?php
include ("../inc/config.inc.php");
include ("../inc/mysql.inc.php");
include ("inc/tool.inc.php");
$link = connect();
$select_son = execute($link,"select * from sfk_son_module where id ={$_GET['id']}")->fetch_assoc();

if (isset($_POST['submit'])) {
    $son_type = "update";
    include ("check/son_module_check.inc.php");
    $_POST = escape($link,$_POST);
    $query = "UPDATE sfk_son_module set father_module_id = {$_POST['father_module_id']},
        module_name = '{$_POST['module_name']}', info = '{$_POST['info']}',
        member_id = '{$_POST['member_id']}', sort = '{$_POST['sort']}' 
        where id = {$_GET['id']} ";
    $update_return = execute($link,$query);
    if ($link->affected_rows) {
        skip('son_module.php','ok','修改字板块成功');
    } else {
        skip("son_module_update.php? {$_GET['id']}",'error','添加子版块失败');
    }

}
?>
<?php
$template['title'] = '修改子板块';
include 'inc/header.inc.php'
?>
<div id="main">
    <div class="title" style="margin-bottom:20px;">修改子版块</div>
    <form method="post">
        <table class="au">
            <tr>
                <td>所属父版块</td>
                <td>
                    <select name="father_module_id">
                        <?php
                            $select_query = "select id,module_name from sfk_father_module ";
                            $arr = execute($link,$select_query);
                            while ($str = $arr->fetch_assoc()) {
                                if ($select_son['father_module_id'] == $str['id']) {
                                    echo "<option  selected='selected' value='{$str['id']}'>{$str['module_name']}</option>";
                                } else {
                                    echo "<option value='{$str['id']}'>{$str['module_name']}</option>";
                                }
                            }
                        ?>
                    </select>
                </td>
                <td>
                    必须选择一个所属的父版块
                </td>
            </tr>
            <tr>
                <td>版块名称</td>
                <td><input value="<?=$select_son['module_name']?>" name="module_name" type="text" /></td>
                <td>
                    版块名称不得为空，最大不得超过66个字符
                </td>
            </tr>
            <tr>
                <td>版块简介</td>
                <td>
                    <textarea name="info"><?=$select_son['info']?></textarea>
                </td>
                <td>
                    简介不得多于255个字符
                </td>
            </tr>
            <tr>
                <td>版主</td>
                <td>
                    <select name="member_id">
                        <option  value="<?=$select_son['member_id']?>">======请选择一个会员作为版主======</option>
                    </select>
                </td>
                <td>
                    你可以在这边选一个会员作为版主
                </td>
            </tr>
            <tr>
                <td>排序</td>
                <td><input value="<?=$select_son['sort']?>"  name="sort"  type="text" /></td>
                <td>
                    填写一个数字即可
                </td>
            </tr>
        </table>
        <input style="margin-top:20px;cursor:pointer;" class="btn" type="submit" name="submit" value="添加" />
    </form>
</div>